#include <stdio.h>
#define MAX_SIZE 100000

void InsertSort(int a[], int size)
{
    for (int i = 1; i < size; i++)
    {
        if (a[i] < a[i - 1])
        {
            int tmp = a[i];
            int j = i - 1;
            while (a[j] > tmp)
            {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = tmp;
        }
    }
}

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        printf("%d\t", a[i]);
    }
}

int main()
{
    printf("\n\n========================================================================\n\n");

    int a[10] = {6, 98, 56, 32, 1, 20, 3, 45, 14, 9};
    print(a, 10);
    printf("\n");
    InsertSort(a, 10);
    print(a, 10);

    // char strs[MAX_SIZE] = {0};
    // char c = '0';
    // int i = 0;
    // while ((c = getchar()) != '\n')
    // {
    //     strs[i++] = c;
    // }
    // printf("%s", strs);

    // char str[MAX_SIZE] = {0};
    // gets(str);
    // printf("%s", str);

    printf("\n\n========================================================================\n\n");
}